import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { LayuiVueResolver } from 'unplugin-vue-components/resolvers'



const pathResolve = (dir) => {
  return resolve(__dirname, '.', dir)
}
//手动导入
// import ElementPlus from 'unplugin-element-plus/vite'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    //手动导入
    // ElementPlus(),
    AutoImport({
      resolvers: [ElementPlusResolver(), LayuiVueResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver(), LayuiVueResolver()],
    })
  ],
  //解析配置
  resolve: {
    //路劲别名
    alias: [
      {
        find: '@',
        replacement: pathResolve('src')
      }, {
        find: '@build',
        replacement: pathResolve('build')
      }
    ]
  },
  server: {
    hmr: true
  },
  "compilerOptions": {
    "jsx": "preserve"
  }
})
